package Server;

import java.net.*;
import java.util.ArrayList;
import java.util.List;

import JDBC.DBAccess;
import Printer.Printer;
import Spooler.User;

public class serverSpooler {
	List<User> UserList;
	List<Printer> PrinterList;
	
	public void setUserList(List<User> userList)
	{
		this.UserList = userList;
	}
	
	public void setPrinterList(List<Printer> printerList)
	{
		this.PrinterList = printerList;
	}
	
    public static void main(String[] args) {
    	
    	List<User> UserList = new ArrayList<User>();
     	List<Printer> PrinterList = new ArrayList<Printer>();
        
        ServerSocket serverSocket = null; 
        DBAccess dba = new DBAccess();
        dba.loadPrtInfo(PrinterList);
        dba.loadUserInfo(UserList);
	
        try {
            serverSocket = new ServerSocket(9002);
            
            while (true) {
            	Socket socket = serverSocket.accept();
                Thread thread = new perClinetThread(socket, PrinterList, UserList);
                thread.start();
            }
            
        }
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
    
    }
}
